/*
 * Created on 12/Abr/2004
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package org.cyborgas.xmltool.actions;

import java.io.File;

import org.cyborgas.xmltool.MainWindow;
import org.cyborgas.xmltool.tabsheets.XslTransformTab;
import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;


/**
 * @author rino
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class XslSaveOutputAsAction extends Action {
	private MainWindow window;
	private XslTransformTab tab;

	public XslSaveOutputAsAction(MainWindow window, XslTransformTab tab) {
		this.window = window;
		this.tab = tab;
		setText("Save &Output As...");
		setToolTipText("Save the output from the XSL Tranformation");
//		setImageDescriptor(Util.getImageDescriptor("fileopen"));
	}

	public void run() {
		FileDialog dialog =
			new FileDialog(window.getShell(), SWT.SAVE);
		dialog.setFilterExtensions(new String[] {"*.xml", "*.html", "*.*"});
		dialog.open();

		String file = dialog.getFileName();
		if (file != null && !file.equals("")) {
			tab.outputFile = new File(dialog.getFilterPath(), file);
			tab.transform();
		}

	}	

}
